home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / lib / stack.mli < prev    next >
Encoding:
Text File  |  1993-09-24  |  990 b   |  27 lines  |  [TEXT/MPS ]

  1. (* Stacks *)
  2.  
  3. (* This module implements stacks (LIFOs), with in-place modification. *)
  4.  
  5. type 'a t mutable;;
  6.         (* The type of stacks containing elements of type ['a]. *)
  7.  
  8. exception Empty;;
  9.         (* Raised when [pop] is applied to an empty stack. *)
  10.  
  11. value new: unit -> 'a t
  12.         (* Return a new stack, initially empty. *)
  13.   and push: 'a -> 'a t -> unit
  14.         (* [push x s] adds the element [x] at the top of stack [s]. *)
  15.   and pop: 'a t -> 'a
  16.         (* [pop s] removes and returns the topmost element in stack [s],
  17.            or raises [Empty] if the stack is empty. *)
  18.   and clear : 'a t -> unit
  19.         (* Discard all elements from a stack. *)
  20.   and length: 'a t -> int
  21.         (* Return the number of elements in a stack. *)
  22.   and iter: ('a -> 'b) -> 'a t -> unit
  23.         (* [iter f s] applies [f] in turn to all elements of [s], from the
  24.            element at the top of the stack to the element at the
  25.            bottom of the stack. The stack itself is unchanged. *)
  26. ;;
  27.